﻿<%@ Page Language="C#" MasterPageFile="~/ad/AdminFShop.master" AutoEventWireup="true" CodeFile="ManageNews.aspx.cs" Inherits="ad_ManageNews" Title="Untitled Page" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
	   <td align="right" 
            style="padding: 10px; height: 21px; text-align: center; font-family: TAhoma; font-size: 20px; background-color: #808080; color: #FFFFFF;" 
            id="Tieude">	        	    
	       QUẢN LÝ TIN TỨC</td>        
	</tr>
	<!--Start add new-->
	<tr  style="width:100%;">
	   <td align="right" style="padding: 10px; margin: 10px;">

           Chọn danh mục :<asp:DropDownList ID="DropDownList2" runat="server" 
               AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="Cate_Name" 
               DataValueField="Cate_ID" 
               onselectedindexchanged="ddlCategory_SelectedIndexChanged" Width="200px">
           </asp:DropDownList>
           <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
               ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
               SelectCommand="SELECT * FROM [Category]"></asp:SqlDataSource>
           <asp:Button ID="Button1" runat="server" onclick="btnSearch_Click1" 
               Text="Hiển thị tất cả" />

        </td>        
	</tr>
	<!--End add new-->

	<tr>
		<td valign="top" style="width:100%;" >
		    <div>        
             
		    <asp:GridView ID="grdNews" runat="server" AllowPaging="True" 
			    AutoGenerateColumns="False" DataKeyNames="News_ID" Width="100%"
			    ForeColor="Black" BorderStyle="None" BorderWidth="1px" 
			    PageSize="15"
			    CellPadding="4" GridLines="Vertical" 
			    OnPageIndexChanging="grdNews_PageIndexChanging" 
			    OnRowCommand="grdNews_RowCommand" OnRowDataBound="grdNews_RowDataBound" 
                    BackColor="White" BorderColor="#DEDFDE">
			    <Columns>        
				     <asp:TemplateField>
					    <ItemStyle HorizontalAlign="Center" Width="30px" />
					    <ItemTemplate>
						    <asp:CheckBox ID="chkCheck" runat="server" />                               
					    </ItemTemplate>
				    </asp:TemplateField> 
				    <asp:TemplateField HeaderText="ID">            
					    <ItemStyle Width="30px" HorizontalAlign="Center" />
					    <ItemTemplate>
						    <asp:Label ID="News_ID" runat="Server" Text='<%#Eval("News_ID") %>' ></asp:Label>
					    </ItemTemplate>
				    </asp:TemplateField>				 
				     <asp:TemplateField HeaderText="Tiêu đề">            
					    <ItemStyle HorizontalAlign="Left" />
					    <ItemTemplate>
					        <a href='<%# "EditNews.aspx?News_ID=" + Eval("News_ID") %>'>
						        <asp:Label ID="Product_Pro_Name" runat="Server" Text='<%#Eval("News_Title") %>'></asp:Label>
						    </a>
					    </ItemTemplate>
				    </asp:TemplateField>    
				        
				     <asp:TemplateField HeaderText="Ngày viết">            
					    <ItemStyle Width="160px" />
					    <ItemTemplate>
						    <asp:Label ID="News_CreateDate" runat="Server" Text='<%#Eval("News_CreateDate") %>'></asp:Label>
					    </ItemTemplate>
				    </asp:TemplateField>	
    			    
    			    <asp:TemplateField  HeaderText="Hiển thị">
					<ItemStyle HorizontalAlign="Center" Width="50px" />
					<ItemTemplate>
						<asp:ImageButton ID="btnActive" 
						CommandArgument='<%# Eval("News_ID") %>' 
						CommandName="active_News"  ImageUrl="Images/check.gif" 
						runat="server" OnClientClick = "javascript:return confirm('Bạn có chắc chắn không ?');"/></a>                            
					</ItemTemplate>
				</asp:TemplateField>     
    				     
				     <asp:TemplateField HeaderText="Danh mục">
                         <ItemTemplate>
                             <asp:DropDownList ID="DropDownList1" runat="server" 
                                 DataSourceID="SqlDataSource1" DataTextField="Cate_Name" 
                                 DataValueField="Cate_ID" SelectedValue='<%# Eval("Cate_ID") %>'>
                             </asp:DropDownList>
                             <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                 ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                                 SelectCommand="SELECT [Cate_ID], [Cate_Name] FROM [Category]">
                             </asp:SqlDataSource>
                         </ItemTemplate>
                     </asp:TemplateField>
    				     
				    <asp:TemplateField >
					    <ItemStyle Width="160px" />
					    <HeaderTemplate>
					    <asp:Label ID="Label3" runat="server" Text="Chức năng" ></asp:Label>                   
					    </HeaderTemplate>
					    <ItemTemplate>                                
						    <asp:HyperLink ID="lnkEdit" runat="server" Font-Bold="True" 
                                NavigateUrl='<%# "EditNews.aspx?News_ID=" + Eval("News_ID") %>' 
                                ImageUrl="~/images/ico/hieuchinh.jpg">
							    <asp:Image ID="ImageEdit" ToolTip="Sửa thông tin" runat="server" ImageUrl="Images/edit.gif" />
						    </asp:HyperLink>                                
						     <asp:ImageButton ID="btnDelete" CommandArgument='<%# Eval("News_ID") %>' 
                                CommandName="delete_News"  ImageUrl="~/images/ico/xoa.jpg" runat="server"  
						     OnClientClick = "javascript:return confirm('Bạn có chắc chắn không ?');"/>                                             
    						 
					    </ItemTemplate>
					    <ItemStyle Wrap="False" />
				    </asp:TemplateField>
			    </Columns>      
			    <PagerSettings FirstPageText="Trang đầu" LastPageText="Trang cuối" NextPageText="&gt;&gt;"
			      PageButtonCount="5" PreviousPageText="&lt;&lt;" />     
			    <pagerstyle backcolor="#F7F7DE" forecolor="Black" horizontalalign="Right" />
			    <RowStyle BorderColor="Black" BorderWidth="1px" BackColor="#F7F7DE" />
			    <EmptyDataTemplate>
                    Chưa có dữ liệu trong danh mục này !
                </EmptyDataTemplate>
			    <FooterStyle BackColor="#CCCC99" />
			    <selectedrowstyle backcolor="#CE5D5A" font-bold="True" forecolor="White" />
			    <headerstyle backcolor="#6B696B" font-bold="True" forecolor="White" />
			    <alternatingrowstyle backcolor="White" />
		        <SortedAscendingCellStyle BackColor="#FBFBF2" />
                <SortedAscendingHeaderStyle BackColor="#848384" />
                <SortedDescendingCellStyle BackColor="#EAEAD3" />
                <SortedDescendingHeaderStyle BackColor="#575357" />
		    </asp:GridView>            
		      
		       
		    </div>
		</td>
	</tr>
<!--Start button-->
 <tr  style="width:100%;">
        <td align="right">
			&nbsp;</td>        
  </tr>
<!--End button-->  
 <tr  style="width:100%;">
        <td align="right">
			<table align="left" style="width: 100%; float: left">
                <tr>
                    <td style="height: 23px; width: 80px;" align="left">
                        <dx:ASPxHyperLink ID="ASPxHyperLink2" runat="server" Text="Thêm mới" 
                            CssClass="dxeButtonEditButton" 
                            NavigateUrl="~/ad/EditNews.aspx" Width="80px"  />

                    </td>
                    <td align="left" width="80" style="height: 23px">
                        <dx:ASPxHyperLink ID="ASPxHyperLink3" runat="server" Text="Chọn hết" 
                            onclick="CheckAll();" CssClass="dxeButtonEditButton" Width="80px" />

                    </td>
                    <td align="left" width="80" style="height: 23px">
                        <dx:ASPxHyperLink ID="ASPxHyperLink1" runat="server" Text="Bỏ chọn hết" 
                            onclick="UnCheckAll();" CssClass="dxeButtonEditButton" Width="80px" />
                          
                    </td>
                    <td align="left" style="height: 23px; width: 261px;">
                        <asp:LinkButton ID="btnDeleteAll" runat="server" OnClick="btnDeleteAll_Click" 
			OnClientClick= "javascript:return confirm('Bạn có chắc chắn không ?');" CssClass="dxeButtonEditButton" 
                            Width="80px" >Xóa hết</asp:LinkButton>
                          
                    </td>
                    <td style="height: 23px">
                    </td>
                </tr>
            </table>
        </td>        
  </tr>
</table>
<script language="javascript" type="text/javascript">        
        function CheckAll()
        {            
            for(i=0;i<document.getElementsByTagName("input").length;i++)
            {
                if(document.getElementsByTagName("input")[i].type == "checkbox")
                {
                    document.getElementsByTagName("input")[i].checked = true;                   
                }
            }
            return true;
        }
        
        function UnCheckAll()
        {            
            for(i=0;i<document.getElementsByTagName("input").length;i++)
            {
                if(document.getElementsByTagName("input")[i].type == "checkbox")
                {
                    document.getElementsByTagName("input")[i].checked = false;                   
                }
            }
            return true;
        }
    </script>
</asp:Content>

